package com.java.control.impl;


import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;

import com.java.control.AbstractAdminCommandController;
import com.java.control.search.ProductSearchCond;
import com.java.control.search.SearchStat;
import com.java.entity.Product;
import com.java.service.ProductService;


/**
 * 产品信息查询
 * @author wqf
 * Nov 27, 2011 3:36:30 PM
 */
public class ShowProductListController extends AbstractAdminCommandController {

	public ShowProductListController(){
		this.setCommandClass(ProductSearchCond.class);
	}	
	
	protected ModelAndView executeRequest(HttpServletRequest request,HttpServletResponse response,Object command)
		throws Exception{
		
		ProductSearchCond searchCond=(ProductSearchCond)command;
		ModelAndView mav = new ModelAndView(this.view);
		searchCond.setPageSize(10L);
		SearchStat searchStat=this.productService.getSearchStat(Product.class, searchCond);
		List<Product> productList = this.productService.getProductList(searchCond);
		mav.addObject("searchStat", searchStat);
		mav.addObject("productList", productList);
		mav.addObject("searchCond", searchCond);
		return mav;		
	}
		
	private String view;
	private ProductService productService;


	public void setProductService(ProductService productService) {
		this.productService = productService;
	}

	public void setView(String view) {
		this.view = view;
	}
	
}
